/**
 * @file codeforces/1691/c/main
 * @brief
 * @see
 * @author Ruiming Guo (guoruiming@stu.scu.edu.cn)
 * @copyright 2022
 * @date 2022/6/17 22:30:07
 **/

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int N = INF;
int main() {
  // High rating and good luck!
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    string s, t;
    cin >> n >> s >> t;
    if (count(s.begin(), s.end(), 'b') != count(t.begin(), t.end(), 'b')) {
      cout << "NO\n";
      continue;
    }
    int j = 0;
    bool ok = true;
    for (int i = 0; i < n; ++i) {
      if (s[i] == 'b') continue;
      while (t[j] == 'b') j += 1;
      if (s[i] != t[j] || (s[i] == 'a' && i > j) || (s[i] == 'c' && i < j)) {
        ok = false;
        break;
      }
      j += 1;
    }
    cout << (ok ? "YES\n" : "NO\n");
  }
  return 0;
}
